{extend name='public/base' /}
{block name='content'}
{include file='public/content_header' /}
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <!-- 表单头部 -->
                <div class="card-header">
                    <div class="btn-group">
                        <a class="btn flat btn-sm btn-default BackButton">
                            <i class="fas fa-arrow-left"></i>
                            返回
                        </a>
                    </div>
                </div>
                <!-- 表单 -->
                <form id="dataForm" class="form-horizontal dataForm" action="" method="post" enctype="multipart/form-data">
                    <!-- 表单字段区域 -->
                    <div class="card-body">
                        <div class="form-group row">
    <label for="name" class="col-sm-2 col-form-label">名称</label>
    <div class="col-sm-10 col-md-4 formInputDiv">
        <input id="name" name="name" value="{$data.name|default=''}" placeholder="请输入名称" type="text" class="form-control fieldText">
    </div>
</div>
    <div class="form-group row">
        <label for="img" class="col-sm-2 col-form-label">图片</label>
        <div class="col-sm-10 col-md-4 formInputDiv"> 
            <div class="input-group">
                <input id="img_file" name="img_file" type="file" class="file-loading " data-initial-preview="{if isset($data)}{$data.img}{/if}">
                <input name="img" id="img" value="{$data.img|default=''}" hidden placeholder="请上传图片" class="fieldImage">
                <script>
                     initUploadImg('img');
                </script>            
            </div>
        </div>
    </div><div class="form-group row">
    <label for="jump_type" class="col-sm-2 col-form-label">跳转类型</label>
    <div class="col-sm-10 col-md-4 formInputDiv">
        <input id="jump_type" name="jump_type" value="{$data.jump_type|default='0'}" placeholder="请输入跳转类型" type="text" class="form-control fieldText">
    </div>
</div>
<div class="form-group row">
    <label for="jump_target" class="col-sm-2 col-form-label">跳转目标</label>
    <div class="col-sm-10 col-md-4 formInputDiv">
        <input id="jump_target" name="jump_target" value="{$data.jump_target|default=''}" placeholder="请输入跳转目标" type="text" class="form-control fieldText">
    </div>
</div>
<div class="form-group row">
    <label for="sort_number" class="col-sm-2 col-form-label">排序</label>
    <div class="col-sm-10 col-md-4 formInputDiv">
         <div class="input-group">
            <input id="sort_number" name="sort_number" value="{$data.sort_number|default='1000'}" placeholder="请输入排序" type="number" class="form-control fieldNumber">
        </div>
    </div>
</div>
<script>
    $('#sort_number')
        .bootstrapNumber({
            upClass: 'success',
            downClass: 'primary',
            center: true
        });
</script>

                    </div>
                    <!-- 表单底部 -->
                    <div class="card-footer">
                        <div class="row">
                            <div class="col-sm-2">
                            </div>

                            <div class="col-sm-10 col-md-4 formInputDiv">

                                <div class="btn-group">
                                    <button type="submit" class="btn btn-sm btn-primary dataFormSubmit">
                                        保 存
                                    </button>
                                </div>
                                <div class="btn-group">
                                    <button type="reset" class="btn btn-sm btn-default dataFormReset">
                                        重 置
                                    </button>
                                </div>

                                {if !isset($data)}
                                <div class="btn-group float-right createContinueDiv">
                                    <input type="checkbox" class="form-check-input" value="1" id="_create" name="_create" title="继续添加数据">
                                    <label class="form-check-label" for="_create">继续添加</label>
                                </div>
                                {/if}
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
<script>
    /** 表单验证 **/
    $('#dataForm').validate({
        rules: {
                'name': {
                required: true,

    },
    'img': {
                required: true,

    },
    'jump_type': {
                required: true,

    },
    'jump_target': {
                required: true,

    },
    'sort_number': {
                required: true,

    },

        },
        messages: {
                'name': {
               required: "名称不能为空",

    },
    'img': {
               required: "图片不能为空",

    },
    'jump_type': {
               required: "跳转类型不能为空",

    },
    'jump_target': {
               required: "跳转目标不能为空",

    },
    'sort_number': {
               required: "排序不能为空",

    },

        }
    });
</script>
{/block}